<!--
+----------------------------------------------------------------------
| 友得云客  - 开启房产营销新纪元
+----------------------------------------------------------------------
| Copyright (c) 2019~2023 优得（西安）信息科技有限公司版权所有
+----------------------------------------------------------------------
| Licensed 友得云客不是自由软件 未经允许不可移除相关版权
+----------------------------------------------------------------------
| Author: www.youdeyunke.com
+----------------------------------------------------------------------
-->
<template>
    <div v-loading="loading">
        <el-form v-loading="loading" label-position="right" label-width="120px" >
            <el-form-item label="公司名称" required>
                <el-input v-model="company_name" style="width: 400px" />
            </el-form-item>

            <el-form-item label="客服电话" required>
                <el-input required v-model="service_mobile" style="width: 400px" />
            </el-form-item>

            <el-form-item label="客服微信号">
                <el-input v-model="service_wechat" style="width: 400px" />
            </el-form-item>




            <el-form-item label="客服微信二维码">
                <image-picker v-model="service_wechat_qr" width="100" height="100" :canDelete="false" />
                <info-tip tipText="最佳图片尺寸 宽度100px，高度100px 或同比例" />
            </el-form-item>

          <el-form-item label="后台LOGO">
            <image-picker v-model="logo" width="100" height="100" :canDelete="false" />
            <info-tip tipText="用于管理后台左上角显示,最佳图片尺寸 宽度100px，高度50px 或同比例" />
          </el-form-item>

          <el-form-item label="关于我们">
            <el-input v-model="about_us" style="width: 400px" type="textarea" :rows="12" :show-word-limit="true"
                      maxlength="300" />
          </el-form-item>

          <el-form-item label="免责声明">
            <el-input v-model="statement" style="width: 400px" type="textarea" :rows="12" :show-word-limit="true"
                      maxlength="300" />

            <info-tip tipText="免责声明用于显示在厂房详情页面底部" />
          </el-form-item>

        <el-form-item>
            <el-button type="primary" :disabled="loading" :loading="loading" size="small" icon="el-icon-check"
                @click="submitCompanyConfig">保存设置</el-button>
        </el-form-item>
        </el-form>
    </div>
</template>

<script>
import { updateWeappInfo } from "@/api/myconfig";
export default {
    name: 'sysinfo',
    props: {
        config: { type: Object, default: null },
    },
    watch: {
        config: {
            deep: true,
            handler(val, oldVal) {
                this.company_name = val.company_name;
                this.service_mobile = val.service_mobile;
                this.service_wechat = val.service_wechat;
                this.service_wechat_qr = val.service_wechat_qr;
                this.about_us = val.about_us;
                this.statement = val.statement;
                this.logo = val.logo;
            }
        }
    },
    data() {
        return {
            company_name: '',
            service_mobile: '',
            service_wechat: '',
            service_wechat_qr: '',
            about_us: '',
            statement: '',
            logo: '',
            loading: false,
        }
    },

    methods: {
        submitCompanyConfig: function () {

            if (!this.company_name) {
                this.$message.error("请填写公司名称");
                return;
            }

            if (!this.service_mobile) {
                this.$message.error("请填写客服电话");
                return;
            }
            this.loading = true
            updateWeappInfo({
                company_name: this.company_name,
                service_mobile: this.service_mobile,
                service_wechat: this.service_wechat,
                logo: this.logo,
                service_wechat_qr: this.service_wechat_qr,
                about_us: this.about_us,
                statement: this.statement,
            }).then((resp) => {
                this.loading = false
                if (resp.code != 0) {
                    return
                }
                // this.loadConfig();
                this.$emit("updateConfig")
                this.$message.success("保存成功")
            })

        },
    },

}
</script>

<style></style>
